import json

defaultConfig = {
            'funcMode': 'date2',
            'textColor': [91, 252, 91],
            'dateColorChange': True,
            'brightness': 0.1,
        }

def setConfig(configDict):
    global defaultConfig
    with open('config.conf', 'w') as f:
        print(configDict)
        f.write(str(json.dumps(configDict)))

def getConfig():
    global defaultConfig
    try:
        with open('config.conf', 'r') as f:
            data = f.read()
            if(data == ''):
                with open('config.conf', 'w') as f:
                    f.write(str(json.dumps(defaultConfig)))
                configDict = defaultConfig
            else:
                configDict = json.loads(data)
            return configDict
    except OSError:
        return defaultConfig
